﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Antlr.Runtime.Tree;
using gxc2csharp.Translator.GxcToCTransform;
namespace GxcToCsharpParser.TreeWalkers
{
   public class GenericWalker
   {
      public void WalkTree(CommonTree tree,int level)
      {
         
         
         if (tree == null)
            return;
         string space = new string(' ', level*4);
        
         Console.WriteLine("{0}{1}( {2} )", space, tree.Text, gxc2csharp.Translator.GxcToCTransform.GxcParser.tokenNames[tree.Type]);
         if (tree.Children == null)
            return;
         
         foreach (var child in tree.Children)
         {
            CommonTree node = (CommonTree)child;
            WalkTree(node,level+1);
         }
      }
   }
}
